from .condition import Condition


class Comparison(Condition):
    
    # Operators:
    EQ = 1
    NE = 2
    GT = 3
    GE = 4
    LT = 5
    LE = 6
    
    def __init__(self, left_expr, right_expr, op=EQ):
        
        Condition.__init__(self)
        
        self.__left = left_expr
        self.__right = right_expr
        self.__op = op
        
    def _is_true(self, scope):
        
        l = self.__left.eval(scope)
        r = self.__right.eval(scope)
        
        return {
            EQ: l == r,
            NE: l != r,
            GT: l > r,
            GE: l >= r,
            LT: l < r,
            LE: l <= r
        }[self.__op]
        

        